package com.aso114.project.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.aso114.project.R;
import com.aso114.project.base.BaseApplication;
import com.aso114.project.bean.OrderBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OrderItemAdapter extends BaseAdapter {


    List<OrderBean.JingPinList> dataary;
    public OrderItemAdapter(List<OrderBean.JingPinList> araydata) {

        dataary = araydata;
    }

    @Override
    public int getCount() {
        return dataary.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView != null) {
            holder = (ViewHolder) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(BaseApplication.getInstance().getBaseContext()).inflate(R.layout.adapter_order_item, parent, false);
            holder = new ViewHolder(convertView);

            holder.orderItemTitle.setText(dataary.get(position).getTitle());
            holder.orderItemPrice.setText("￥"+dataary.get(position).getBuyPrice());
            convertView.setTag(holder);
        }
        return convertView;
    }

    static
    class ViewHolder {
        @BindView(R.id.order_item_title)
        TextView orderItemTitle;
        @BindView(R.id.order_item_price)
        TextView orderItemPrice;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
